﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoolCode.Linq;
using CoolCode.Entities;
using CoolCode.Services ;

namespace CoolCode.Web.UI.Views.IC
{
    public partial class History : SearchPage<SearchItem, Outbound, IInspectionService> 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            handleEvents();
            if (!IsPostBack)
            {
                cdrCheckDateFr.Value = DateTime.Now.Date.AddMonths(-12);
                cdrCheckDateTo.Value = DateTime.Now.Date;
            }
        }

        public override IQueryBuilder<Outbound> CreateFilter()
        {
            return QueryBuilder.Create<Outbound>()
                .Between(c => c.Date, cdrCheckDateFr.Value.GetValueOrDefault(), cdrCheckDateTo.Value.GetValueOrDefault());
        }

        protected void handleEvents()
        {
            this.Setup(lnkSearch, searchList, c =>
            {
                c.Result.ForEach(item => item.Title = "产品规格：" +item.Title );
                searchList.Model = c.Result;
                searchList.DataBind();
                udpHeader.Update(); 
            },
            c =>
            {
                udpHeader.Alert(c.Exception);
            });
 

        }



    }
}
